<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2024/3/20
 * Time: 16:16
 */

namespace app\controller\admin;

use think\facade\Db;
use think\facade\View;

class Bangmang
{
    public function index(){
        return View::fetch('/admin/bangmang');
    }

    public function yemian(){
        $post = input('post.');
        if (!empty($post))
            cache('yemian', $post);
        $info = cache('yemian');
        empty($info) && $info = [];
        View::assign('info',$info);
        return View::fetch('/admin/yemian');
    }

    public function yuanqu($id = 0){
        $post = input('post.');
        $where = [];
        view::assign('page',input('page',1));
        view::assign('size',input('size',20));
        !empty($post['area']) && $where[] = ['y_area','like',$post['area']];
        if (!empty($id)){
            if(!empty($post)){
                Db::name('bangmang_qiyeyuanqu')
                    ->where('id',$id)
                    ->update($post);
                return redirect('/admin/bangmang/yuanqu?page='.input('page',1));
            }
            $info = Db::name('bangmang_qiyeyuanqu')->where('id',$id)->find();
            View::assign('info',$info);       
            return View::fetch('/admin/yuanqu_info');
        }
        $list = Db::name('bangmang_qiyeyuanqu')
            ->where($where)
            ->paginate(['page' => input('page',1),'list_rows' => input('size',20)]);
        View::assign('list',$list);
        return View::fetch('/admin/yuanqu');
    }
    public function save(){

    }
}